//
//  ExceptionsViewController.m
//  SmartWatch
//
//  Created by zwj on 2022/11/23.
//

#import "ExceptionsViewController.h"
#import "InformationViewController.h"
#import <WebKit/WebKit.h>

@interface ExceptionsViewController ()

@end

@implementation ExceptionsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"免责条款";
    
}

- (void)initSubviews {
    [super initSubviews];
    
    MyLinearLayout *top = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
    top.myHorzMargin = 16;
    top.myTop = NavigationContentTop + 15;
    top.padding = UIEdgeInsetsMake(15, 15, 15, 15);
    top.gravity = MyGravity_Vert_Center;
    top.myHeight = 70;
    top.subviewHSpace = 15;
    [top az_setGradientBackgroundWithColors:@[HexColor(@"#FFE3E3"),HexColor(@"#FFEBEB")] locations:@[@0.0,@1.0] startPoint:CGPointMake(0, 1) endPoint:CGPointMake(1, 1)];
    [self.view addSubview:top];
    
    {
        UIImageView *imageView = [[UIImageView alloc]initWithImage:UIImageMake(@"login_warn")];
        imageView.mySize = CGSizeMake(40, 40);
        [top addSubview:imageView];
        
        MyLinearLayout *right = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
        right.weight = 1;
        right.subviewVSpace = 10;
        [top addSubview:right];
        
        {
            UILabel *name = [UILabel createLabelText:@"警告" font:UIFontBoldMake(17) textColor:HexColor(@"#BE2222")];
            name.mySize = kAutoSize;
            [right addSubview:name];
            
            UILabel *detail = [UILabel createLabelText:@"绝对不能作为医学诊断及医疗用途" font:UIFontMake(14) textColor:HexColor(@"#BE2222")];
            detail.mySize = kAutoSize;
            [right addSubview:detail];
        }
    }
    
    WKWebView *wkWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, NavigationContentTop + 100, kScreenWidth, kScreenHeight - NavigationContentTop - 200)];
//    wkWebView.UIDelegate = self;
//    wkWebView.navigationDelegate = self;
    [wkWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com/"]]];
    wkWebView.allowsBackForwardNavigationGestures = NO;
    [self.view addSubview:wkWebView];
    
    MyLinearLayout *bottom = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    bottom.myHorzMargin = 0;
    bottom.myHeight = 100;
    bottom.myBottom = 0;
    bottom.gravity = MyGravity_Horz_Center;
    bottom.subviewVSpace = 10;
    [self.view addSubview:bottom];
    
    {
        
        UIButton *submitBtn = [UIButton createButtonText:@"下一步" font:UIFontMake(14) textColor:COLOR_4];
        submitBtn.myTop = 20;
        submitBtn.myHorzMargin = 28;
        submitBtn.myHeight = 46;
        ViewCorner(submitBtn, 23);
        [submitBtn az_setGradientBackgroundWithColors:@[HexColor(@"#4BD8B1"),HexColor(@"#2CAED8")] locations:@[@0.0,@1.0] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 1)];
        [submitBtn addTarget:self action:@selector(submitBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [bottom addSubview:submitBtn];
    }
    
}

- (void)submitBtnClick {
    
    
    WeakSelf
    [self alertWithTitle:@"我已经阅读，并了解这是非医疗用途的免责声明。" content:@"" sure:@"确定" handler:^{
        InformationViewController *vc = InformationViewController.new;
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }];
}

@end
